package com.huobao.yunying.adapters;

import com.huobao.yunying.entity.Jinritehui;
import com.huobao.yunying.utils.ImageUtils;
import com.huobao.yunying.utils.ImageUtils.OnImageLoadListener;
import com.huobao.zhangying.R;
import com.xrz.sxm.base.utils.ScreenUtil;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.view.Gravity;
import android.widget.ImageView;
import android.widget.LinearLayout.LayoutParams;
import android.widget.TextView;
import joanzapata.android.BaseAdapterHelper;
import joanzapata.android.QuickAdapter;

public class Adapter_jinritehui extends QuickAdapter<Jinritehui> {


	public Adapter_jinritehui(Context context) {
		super(context, R.layout.item_jinritehui);
	}

	@Override
	protected void convert(final BaseAdapterHelper arg0, Jinritehui arg1) {
		final ImageView imageView = arg0.getView(R.id.imageview);
		TextView textView = arg0.getView(R.id.textview);
		TextView tv_price = arg0.getView(R.id.tv_1);
		TextView tv_right = arg0.getView(R.id.tv_2);
		ImageUtils.loadimg(imageView, arg1.getDefault_image(), new OnImageLoadListener() {

			@Override
			public void onLoadSuccess(Drawable drawable) {
				int width = ScreenUtil.getInstant().getDisWidth(context) / 2 - 20;
				int newHight = width * drawable.getIntrinsicHeight() / drawable.getIntrinsicWidth();
				LayoutParams params = (LayoutParams) imageView.getLayoutParams();
				params.width = width;
				params.gravity = Gravity.CENTER_HORIZONTAL;
				params.height = newHight;
				imageView.setLayoutParams(params);
			}
		});
		textView.setText(arg1.getGoods_name());
		tv_price.setText("￥" + arg1.getPrice());
		tv_right.setText(arg1.getStext());
	}

}
